package com.cos.lession72.slice;

import com.cos.lession72.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.DatePicker;
import ohos.agp.components.Picker;
import ohos.agp.components.Text;
import ohos.agp.utils.Color;
import ohos.agp.window.dialog.ToastDialog;

public class DatePickerAbilitySlice extends AbilitySlice {
    int count=0;
    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        setUIContent(ResourceTable.Layout_ability_date_picker);
        //获取日期选择器对象
        DatePicker dp = (DatePicker) findComponentById(ResourceTable.Id_data1);

        dp.setValueChangedListener(new DatePicker.ValueChangedListener() {
            @Override
            public void onValueChanged(DatePicker datePicker, int i, int i1, int i2) {
                int year = dp.getYear();
                int month = dp.getMonth();
                int day  = dp.getDayOfMonth();
                Text t = (Text) findComponentById(ResourceTable.Id_myText);
                t.setText(year+"年"+month+"月"+day+"日");
            }
        });
    }
}
